package com.whisper.application.service.service.impl;

import java.util.List;
import com.whisper.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.whisper.application.service.mapper.VrPostMapper;
import com.whisper.application.service.domain.VrPost;
import com.whisper.application.service.service.IVrPostService;

import static com.whisper.common.security.util.SecurityUtils.getUsername;

/**
 * 文章Service业务层处理
 * 
 * @author whisper
 * @date 2024-01-07
 */
@Service
public class VrPostServiceImpl implements IVrPostService 
{
    @Autowired
    private VrPostMapper vrPostMapper;

    /**
     * 查询文章
     * 
     * @param id 文章主键
     * @return 文章
     */
    @Override
    public VrPost selectVrPostById(Long id)
    {
        return vrPostMapper.selectVrPostById(id);
    }

    /**
     * 查询文章列表
     * 
     * @param vrPost 文章
     * @return 文章
     */
    @Override
    public List<VrPost> selectVrPostList(VrPost vrPost)
    {
        return vrPostMapper.selectVrPostList(vrPost);
    }

    /**
     * 新增文章
     * 
     * @param vrPost 文章
     * @return 结果
     */
    @Override
    public int insertVrPost(VrPost vrPost)
    {
        vrPost.setCreateTime(DateUtils.getNowDate());
        vrPost.setCreateBy(getUsername());
        return vrPostMapper.insertVrPost(vrPost);
    }

    /**
     * 修改文章
     * 
     * @param vrPost 文章
     * @return 结果
     */
    @Override
    public int updateVrPost(VrPost vrPost)
    {
        vrPost.setUpdateTime(DateUtils.getNowDate());
        vrPost.setUpdateBy(getUsername());
        return vrPostMapper.updateVrPost(vrPost);
    }

    /**
     * 批量删除文章
     * 
     * @param ids 需要删除的文章主键
     * @return 结果
     */
    @Override
    public int deleteVrPostByIds(Long[] ids)
    {
        return vrPostMapper.deleteVrPostByIds(ids);
    }

    /**
     * 删除文章信息
     * 
     * @param id 文章主键
     * @return 结果
     */
    @Override
    public int deleteVrPostById(Long id)
    {
        return vrPostMapper.deleteVrPostById(id);
    }

    @Override
    public List<VrPost> selectVrPostOrderByCreateTimeLimit(Integer limit) {
        return vrPostMapper.selectVrPostListByCreateTimeLimit(limit);
    }

    @Override
    public List<VrPost> selectGroupByPostList() {
        return vrPostMapper.selectGroupByPostList();
    }

    @Override
    public List<VrPost> selectGroupByPostListLimit(Integer size) {
        return vrPostMapper.selectGroupByPostListLimit(size);
    }

    @Override
    public List<VrPost> selectVrPostListLimit(VrPost vrPost, Integer size) {
        return vrPostMapper.selectVrPostListLimit(vrPost, size);
    }
}
